﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Usercontrol_ControlRegisterNPPSuccess : System.Web.UI.UserControl
{
    ClassExecute.ClassExecute dt;
    string str = webapp4U.Configuration.CurrentConnectionString;
    string error = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["salesp_key"] != null)
            {
                GetInforNPPRegisterSuccess(Request.QueryString["salesp_key"].ToString());
            }
            else
            {
                GetInforNPPRegisterSuccess(Session["UserName"].ToString());
            }
        }
    }
    void GetInforNPPRegisterSuccess(string salesp_key)
    {
        dt = new ClassExecute.ClassExecute();
        DataTable db = dt.Get_Data_DataTable(str, ref error, "k_GetInfoNPPRegisterSuccess", CommandType.StoredProcedure,
            new SqlParameter("@salesp_key",salesp_key ));
        SendMsgToRec(salesp_key, db.Rows[0]["Mobile"].ToString());
        DetailsView1.DataSource = db;
        DetailsView1.DataBind();


    }
    void SendMsgToRec(string salesp_key,string telRec)
    {
        dt = new ClassExecute.ClassExecute();
        bool kq = dt.ExecuteSQl_bool(str, CommandType.StoredProcedure, "k_sendMsgToRecAfterNewRegister", ref error,
            new SqlParameter("@SalespkeyNew", salesp_key),
            new SqlParameter("@TelRec", telRec));

    }
    protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)
    {
        if (e.CommandName == "chon")
        {
            Response.Redirect(webapp4U.Globals.ApplicationPath + "Page/ChangePass/Default.aspx");
        }
    }
}